home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / gnu / gnulib / sipp / include / dynarray.h next >
Encoding:
C/C++ Source or Header  |  1992-09-04  |  3.6 KB  |  128 lines

  1. /* D Y N A R R A Y */
  2. /*
  3.  * This file is part of libdyn.a, the C Dynamic Object library.  It
  4.  * contains the public header file.
  5.  *
  6.  * There are no restrictions on this code; however, if you make any
  7.  * changes, I request that you document them so that I do not get
  8.  * credit or blame for your modifications.
  9.  *
  10.  * Written by Barr3y Jaspan, Student Information Processing Board (SIPB)
  11.  * and MIT-Project Athena, 1989.
  12.  */
  13.  
  14.  
  15. /*
  16.  * dynarray.h -- header file to be included by programs linking against
  17.  * libdyn.a.
  18.  */
  19.  
  20. #ifndef _Dyn_h
  21. #define _Dyn_h
  22.  
  23.  
  24. #ifndef AVAILABLE_ARCHITECTURES
  25. #define AVAILABLE_ARCHITECTURES
  26.  
  27. #ifdef THINK_C
  28. #    define MACINTOSH
  29. #    ifndef __STDC__
  30. #     define __STDC__    /* the compiler is ANSI compatible but doesn't define this */
  31. #    endif
  32. #elif defined(__MSDOS__)
  33. #    ifdef __GNUC__        /* 32 bit DJGPP DOS version w/ GRX library */
  34. #     undef     unix        /* DJGPP has these defined - clean up */
  35. #     undef     __unix
  36. #     undef     __unix__
  37. #     define  GRX        1    /* GRX version */
  38. #     define  GRX32        1    /* and 32 bits */
  39. #    endif
  40. #    ifdef __TURBOC__
  41. #     ifdef     DONT_USE_BGI
  42. #         define GRX        1    /* GRX graphics version */
  43. #         define GRX16   1    /* and 16 bits */
  44. #     else            /* for BGI-based srgp */
  45. #         define IBM_PC
  46. #     endif
  47. #    endif
  48. #elif _AIX
  49. #    define RS6000
  50. #elif sgi
  51. #    define SGI_X /* one day we'll there'll also be SGI_GL */
  52. #elif ultrix
  53. #    define DEC
  54. #elif __unix__
  55. #    define SUN /* either sparc or sun 3 */
  56. #endif
  57.  
  58. #endif /* AVAILABLE_ARCHITECTURES */
  59.  
  60.  
  61. #ifndef SUIT_PROTOTYPE
  62. #    ifdef __cplusplus
  63. #     define SUIT_PROTOTYPE extern "C"
  64. #    else
  65. #     define SUIT_PROTOTYPE
  66. #    endif
  67. #endif /* SUIT_PROTOTYPE */
  68.  
  69.  
  70. #ifndef ANSI_COMPILER
  71. #    if defined(__STDC__) || defined(__cplusplus) || defined(_Windows)
  72. #     define ANSI_COMPILER  1
  73. #    else
  74. #     define ANSI_COMPILER  0
  75. #    endif
  76. #endif
  77.  
  78. #if ANSI_COMPILER
  79. #define CARGS(X)  X
  80. #else
  81. #define CARGS(X)  ()
  82. #endif
  83.  
  84.  
  85. typedef void *ARRAY;
  86.  
  87. #define UNSORTED       0
  88. #define SORTED           1
  89.  
  90. #define SORT_IF_OVER       3
  91. #define QUICKSORT_IF_OVER 10
  92.  
  93. typedef struct DynObject_struct {
  94.      ARRAY    array;
  95.      unsigned short el_size, num_el, size, inc;
  96.      unsigned int debug        : 1;
  97.      unsigned int changed    : 1;
  98.      unsigned int sortStatus    : 1;
  99. } Int_DynObjectRec, *Int_DynObject, DynArrayRec, *DynArray;
  100.  
  101. /* Function macros */
  102. #define DynHigh(obj)    (DynSize(obj) - 1)
  103. #define DynLow(obj)    (0)
  104.  
  105. /* Return status codes */
  106. #define DYN_NOT_FOUND    -1
  107. #define DYN_OK            -1000
  108. #define DYN_NOMEM        -1001
  109. #define DYN_BADINDEX    -1002
  110.  
  111. /* Function declarations */
  112. SUIT_PROTOTYPE DynArray        DynCreate CARGS((int el_size, int inc));
  113. SUIT_PROTOTYPE int        DynDelete CARGS((DynArray obj, int index));
  114. SUIT_PROTOTYPE int        DynDeleteFastButWreckOrdering CARGS((DynArray obj, int index));
  115. SUIT_PROTOTYPE int        DynAdd CARGS((DynArray obj, void *el));
  116. SUIT_PROTOTYPE int        DynDebug CARGS((DynArray obj, int state));
  117. SUIT_PROTOTYPE int        DynSize CARGS((DynArray obj));
  118. SUIT_PROTOTYPE int        DynQsort CARGS((DynArray obj, int first, int last, int (*compar)() ));
  119. SUIT_PROTOTYPE int        DynInsertionSort CARGS((DynArray obj, int first, int last, int (*compar)() ));
  120. SUIT_PROTOTYPE void*        DynGet CARGS((DynArray obj, int num));
  121. SUIT_PROTOTYPE void*        DynFind  CARGS((DynArray obj, void *key, int (*compare)() ));
  122. SUIT_PROTOTYPE int        DynFindIndex  CARGS((DynArray obj, void *key, int (*compare)() ));
  123. SUIT_PROTOTYPE int        DynDestroy CARGS((DynArray obj));
  124. SUIT_PROTOTYPE int        DynEqual CARGS((DynArray a, DynArray b));
  125.  
  126. #endif /* _Dyn_h */
  127. /* DO NOT ADD ANYTHING AFTER THIS #endif */
  128.